# Using the splice function, you can delete or replace elements within
# the array. For instance, if you simply want to delete an element,
# you could write:


# @browser = ("NS", "IE", "Opera");
# splice(@browser, 1, 1);

# You'll see three arguments inside the () of the splice function
# above. The first one is just the name of the array you want to
# splice. The second is the list number of the element where you wish
# to start the splice (starts counting at zero). The third is the
# number of elements you wish to splice. In this case, we just want to
# splice one element so we have 1. The code above deletes the element
# at list number 1, which is "IE" (NS is zero, IE is 1, Opera is
# 2). So now the array has only "NS" and "Opera", just two elements.

# If you want to delete more than one element, change that third
# number to the number of elements you wish to delete. Let's say we
# want to get rid of both "NS" and "IE". We could write:


# @browser = ("NS", "IE", "Opera");
# splice(@browser, 0, 2);

# Now, it starts splicing at list number zero, and continues until it
# splices two elements in a row. Now all that will be left in the
# array is "Opera".

# You can also use splice to replace elements. You just need to list
# your replacement elements after your other three arguments within
# the splice function. So, if we wanted to replace "IE" and "Opera"
# with "NeoPlanet" and "Mosaic", we would write it this way:


# @browser = ("NS", "IE", "Opera");
# splice(@browser, 1, 2, "NeoPlanet", "Mosaic");

# Now the array contains the elements "NS", "NeoPlanet", and
# "Mosaic". As you can see, the splice function can come in handy if
# you need to make large deletions or replacements.




@browser = qw(ie ns opera);
print "$_\n" foreach @browser;
#       name     + start index   + number of elements to delete
splice (@browser,     1,          1);

print "------------------\n";
print "$_\n" foreach @browser;

